package com.personal.sfe.security;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.AntPathMatcher;
import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author: 梁奔
 * @date: 2025/11/06
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "jwt")
public class JwtProperties {

    private List<String> whiteList;

    private final AntPathMatcher pathMatcher = new AntPathMatcher();

    public boolean isWhiteListed(List<String> whiteList, String requestURI) {
        if (CollUtil.isEmpty(whiteList)) {
            return false;
        }
        for (String whitePath : whiteList) {
            if (pathMatcher.match(whitePath, requestURI)) {
                return true;
            }
        }
        return false;
    }
}
